package com.neuronrobotics.replicator.gui.preview.android;

import com.neuronrobotics.opengl.scene.CircleShape;
import com.neuronrobotics.opengl.scene.GLHandles;
import com.neuronrobotics.opengl.scene.SimpleMutableLineNode;
import com.neuronrobotics.opengl.scene.TransformGroupNode;

public class AngleIndicatorGroup extends TransformGroupNode{
	
	private CircleShape theCircle;
	
	private SimpleMutableLineNode lineA;
	private SimpleMutableLineNode lineB;
	
	private float baseCenterX, baseCenterY, baseCenterZ, radius;	
	
	public AngleIndicatorGroup(GLHandles glh, float cx, float cy, float cz, float rad){
		super();
		this.baseCenterX = cx;
		this.baseCenterY = cy;
		this.baseCenterZ = cz; 
		this.radius = rad;
		
		//Initialize circl
		theCircle = CircleShape.getCircleShape(glh, baseCenterX, baseCenterY, baseCenterZ, radius);
		this.addChild(theCircle);
		this.theCircle.setLightsOn(false);	
		theCircle.setColor(1f, 1f,1f,1f);
			
		lineA = new SimpleMutableLineNode(glh, new float[]{baseCenterX,baseCenterY,baseCenterZ,baseCenterX+radius,baseCenterY,baseCenterZ});
		lineB = new SimpleMutableLineNode(glh, new float[]{baseCenterX,baseCenterY,baseCenterZ,baseCenterX+radius,baseCenterY,baseCenterZ});
		

		lineA.setColor(1f,1f,1f,1f);
		lineB.setColor(1f,1f,1f,1f);
		lineA.setLightsOn(false);
		lineB.setLightsOn(false);
			
		
		this.addChild(lineA);
		this.addChild(lineB);
		
	}
	
	public void setStartEndAngle(float startRad, float endRad){
					
		this.theCircle.setStartEndAngle(startRad, endRad);
		lineA.setPointB(baseCenterX + this.radius*(float)Math.cos(startRad),baseCenterY,baseCenterZ+ this.radius*(float)Math.sin(startRad));
		lineB.setPointB(baseCenterX + this.radius*(float)Math.cos(endRad),baseCenterY,baseCenterZ+ this.radius*(float)Math.sin(endRad));
		
	}
	
	
}
